package com.avic.rong.utils;

import android.content.Context;

import com.avic.rong.activity.ArticleDetailActivity;
import com.avic.rong.activity.product.DetailProductActivity;
import com.avic.rong.activity.product.H5Activity;
import com.avic.rong.course.activity.CourseDetailActivity;

/**
 * Creater: Created by wangyz on 2019/8/26.
 * Email: 936804097@qq.com
 */
public class SkipUtils {


    public static void startSkipDetailIntent(Context context,String url, String firstImageUrl){
            if (StringUtils.isEmpty(url)) return;

            String idStr = "";
            if (url.contains("news")){
                if (url.contains(".html")){
                    idStr = url.substring(url.lastIndexOf("/") + 1,url.lastIndexOf("."));
                }else{
                    idStr = url.substring(url.lastIndexOf("/") + 1);
                }
                context.startActivity(ArticleDetailActivity.getIntent(context,idStr));
            }else if(url.contains("contId")){
                idStr = url.substring(url.lastIndexOf("contId") + "contId".length() + 1);
                context.startActivity(ArticleDetailActivity.getIntent(context,idStr));
            }else if(url.contains("appGood")){
                idStr = url.substring(url.lastIndexOf("/") + 1);
                context.startActivity(DetailProductActivity.getIntent(context,idStr));
            }else if( url.contains("good")){
                if (url.contains(".html")){
                    idStr = url.substring(url.lastIndexOf("/") + 1,url.lastIndexOf("."));
                }else{
                    idStr = url.substring(url.lastIndexOf("/") + 1);
                }
                context.startActivity(DetailProductActivity.getIntent(context,idStr));
            }else if(url.contains("study")){
                if (url.contains(".html")){
                    idStr = url.substring(url.lastIndexOf("/") + 1,url.lastIndexOf("."));
                }else{
                    idStr = url.substring(url.lastIndexOf("/") + 1);
                }
                idStr = idStr.substring(1);
                context.startActivity(CourseDetailActivity.getIntent(context,idStr,firstImageUrl,""));
//                context.startActivity(H5Activity.queryIntent(context,url));
            }else{
                 context.startActivity(H5Activity.queryIntent(context,url));
            }
    }



}
